/*
 * @lc app=leetcode.cn id=504 lang=javascript
 *
 * [504] 七进制数
 */

// @lc code=start
/**
 * @param {number} num
 * @return {string}
 */
var convertToBase7 = function(num) {
  if(num === 0) return '0';
  let ret = '', flag = 0;
  if(num < 0) {
    num = -num;
    flag = 1;
  }
  while(num) {
    ret = num % 7 + ret;
    num = (num / 7) | 0;
  }
  return flag === 1 ? '-' + ret : ret;
};
// @lc code=end

